{
LANG : PASCAL
PROB : fact4
}

program FACT4;
const
  fi = 'fact4.in';
  fo = 'fact4.out';
var
  n, res : longint;

function cal(n, k : longint) : longint;
var
  res : longint;
begin
  res := 0;
  while n > 0 do
  begin
    inc(res, n div k);
    n := n div k;
  end;
  cal := res;
end;

function F(n : longint) : longint;
begin
  while n mod 2 = 0 do n := n div 2;
  while n mod 5 = 0 do n := n div 5;
  F := n;
end;

procedure process;
var
  i, j : longint;
begin
  j := (cal(n, 2) - cal(n, 5) - 1) mod 4 + 1;
  res := 1;
  for i := 1 to j do res := (res*2) mod 10;
  for i := 1 to n do
  begin
    j := F(i) mod 10;
    res := (res * j) mod 10;
  end;
end;

begin
  assign(input, fi); reset(input);
  assign(output, fo); rewrite(output);
  read(n);
  process;
  writeln(res);
  close(output);
  close(input);
end.